package com.freightoa.foundation.utlis

import android.content.Context
import androidx.appcompat.app.AlertDialog
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.progressindicator.CircularProgressIndicator

class LoadingDialogHelper(private val context: Context) {

    private var dialog: AlertDialog? = null

    fun showLoadingDialog() {
        val circularProgressIndicator = CircularProgressIndicator(context).apply {
            isIndeterminate = true
            setPadding(16, 16, 16, 16)
        }
        dialog = MaterialAlertDialogBuilder(context)
            .setView(circularProgressIndicator)
            .setMessage("加载中，请稍候...")
            .setCancelable(false)
            .create()
        dialog?.show()
    }

    fun dismissLoadingDialog() {
        dialog?.dismiss()
    }
}